﻿#include "OverlapMesh.h"
#include "Application.h"
#include "MeshTool.h"


OverlapMesh::OverlapMesh(const Configuration& cfg)
  : Mesh(cfg)
{
  Application* app = cfg.Get<Application*>("_app");
  Parser* parser = cfg.Get<Parser*>("_parser");
  {
    Configuration cfg1;
    cfg1.Add<Application*>("_app", app);
    cfg1.Add<Parser*>("_parser", parser);

    parser->SetPrefix("Mesh/StructuredMesh/");
    auto type = parser->Get<std::string>("type");
    _structure_mesh = ObjectFactory::Make<Mesh>(type, cfg1);
  }

  {
    Configuration cfg1;
    cfg1.Add<Application*>("_app", app);
    cfg1.Add<Parser*>("_parser", parser);

    parser->SetPrefix("Mesh/UnStructuredMesh/");
    auto type = parser->Get<std::string>("type");
    _unstructure_mesh = ObjectFactory::Make<Mesh>(type, cfg1);
  }
}

void OverlapMesh::Build()
{
  _structure_mesh->Build();
  _unstructure_mesh->Build();
  console::Info("OverlapMesh::Build");
}

std::shared_ptr<Mesh>& OverlapMesh::GetStructuredMesh()
{
  return _structure_mesh;
}

std::shared_ptr<Mesh>& OverlapMesh::GetUnStructuredMesh()
{
  return _unstructure_mesh;
}
